<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>学生列表(咨询经理)</title>
		<script src="js/global.js"></script>
	</head>

	<body>
		<div class="layui-form-item">
			<form class="layui-form">
				<div class="layui-inline">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-inline" style="width: 100px;">
						<input type="text" id="stuName" autocomplete="off" placeholder="请输入用户名" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">性别</label>
					<div class="layui-input-inline" style="width: 100px;">
						<select id="stuSex" class="layui-select">
							<option value="">请选择</option>
							<option value="男">男</option>
							<option value="女">女</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">咨询师</label>
					<div class="layui-input-inline" style="width: 120px;">
						<select id="aa" name="userId" class="layui-select">
							<option value="杜晨晨">杜晨晨</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">网络咨询师</label>
					<div class="layui-input-inline" style="width: 100px;">
						<select id="entryName"name="entryName" class="layui-select">
							<option value="">请选择</option>
							<option value="胡小豪">胡小豪</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">缴费情况</label>
					<div class="layui-input-inline" style="width: 100px;">
						<select id="isFees" class="layui-select">
							<option value="">请选择</option>
							<option value="已缴费">已缴费</option>
							<option value="未缴费">未缴费</option>
						</select>
					</div>
				</div>
				<input type="button" class="layui-btn" id="souBtn" value="搜索">
			</form>
		</div>

		<!--表格容器-->
		<table id="demo" lay-filter="test"></table>

		<!--追踪记录表格容器-->
		<div style="display: none;" id="zhuizonglook">
			<table id="demo1" lay-filter="test1"></table>
		</div>
		
		<!--头部工具条-->
		<script type="text/html" id="barDemo1">
			<!--<a class="layui-btn " lay-event="add"><i class="layui-icon">&#xe608;</i>录入学生</a>-->
			<a class="layui-btn layui-btn" lay-event="daoru"><i class="layui-icon">&#xe681;</i>导入</a>
			<a class="layui-btn layui-btn" lay-event="daochu"><i class="layui-icon">&#xe67d;</i>导出</a>
			<a class="layui-btn layui-btn" lay-event="resetsay"><i class="layui-icon">&#xe716;</i>批量分配咨询师</a>
			<a class="layui-btn layui-btn" lay-event="yijianconfig"><i class="layui-icon">&#xe62f;</i>一键分配咨询师</a>
		</script>

		<script type="text/html" id="barDemo2">
			<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i>编辑</a>
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i>删除</a>
			<a class="layui-btn  layui-btn-normal layui-btn-xs" lay-event="zhuizongedit"><i class="layui-icon">&#xe63c;</i>跟踪记录</a>
		</script>

		<script type="text/html" id="barDemo3">
			<h2 style="color: grey;">学生追踪记录列表</h2>
		</script>
		
		<div id="tianjiac" style="display: none">
			<form class="layui-form" onsubmit="return false" id="tianjiaf">
				<!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-inline">
						<input type="text" name="stuName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">性别</label>
					<div class="layui-input-inline">
						<input type="radio" name="stuSex" value="男" title="男" checked>
						<input type="radio" name="stuSex" value="女" title="女">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">年龄</label>
					<div class="layui-input-inline">
						<input type="text" name="stuAge" lay-verify="age" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">电话</label>
					<div class="layui-input-inline">
						<input type="text" name="phone" lay-verify="phone" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">学历</label>
					<div class="layui-input-inline">
						<select name="degree" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="本科">本科</option>
							<option value="大专">大专</option>
							<option value="高中">中专</option>
							<option value="高中">高中</option>
							<option value="初中">初中</option>
							<option value="初中">其他</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">状态</label>
					<div class="layui-input-inline">
						<select name="stuStatus" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="待业">待业</option>
							<option value="在职">在职</option>
							<option value="在读">在读</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">来源渠道</label>
					<div class="layui-input-inline">
						<select name="stuSources" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="百度移动端">百度移动端</option>
							<option value="360移动端">360移动端</option>
							<option value="搜狗移动端">搜狗移动端</option>
							<option value="UC移动端">UC移动端</option>
							<option value="直接输入">直接输入</option>
							<option value="QQ">QQ</option>
							<option value="微信">微信</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">来源网站</label>
					<div class="layui-input-inline">
						<select name="stuSourceSite" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="职英A站">职英A站</option>
							<option value="职英B站">职英B站</option>
							<option value="高考站">高考站</option>
							<option value="初中">其他</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">来源关键词</label>
					<div class="layui-input-inline">
						<select name="stuSourceKeyword" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="网络">网络</option>
							<option value="介绍">介绍</option>
							<option value="其他">其他</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">来源部门</label>
					<div class="layui-input-inline">
						<select name="stuSourcesDepartment" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="课程">网络</option>
							<option value="学时">市场</option>
							<option value="学费">教质</option>
							<option value="学历">就业</option>
							<option value="就业">学术</option>
							<option value="其他">其他</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">所在区域</label>
					<div class="layui-input-inline">
						<select name="stuArea" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="郑州">郑州</option>
							<option value="新乡">新乡</option>
							<option value="周口">周口</option>
							<option value="焦作">焦作</option>
							<option value="鹤壁">鹤壁</option>
							<option value="其他">其他</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">学员关注</label>
					<div class="layui-input-inline">
						<select name="stuAttention" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="课程">课程</option>
							<option value="学时">学时</option>
							<option value="学费">学费</option>
							<option value="学历">学历</option>
							<option value="就业">就业</option>
							<option value="其他">其他</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">学员QQ</label>
					<div class="layui-input-inline">
						<input type="text" name="qq" placeholder="请输入" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">微信号</label>
					<div class="layui-input-inline">
						<input type="text" name="wechat" placeholder="请输入" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">是否报备</label>
					<div class="layui-input-inline">
						<select name="isReport" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="是">是</option>
							<option value="否">否</option>
						</select>
					</div>
					<!--	</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">是否缴费</label>
					<div class="layui-input-inline">
						<select name="isFees" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="已缴费">已缴费</option>
							<option value="未缴费">未缴费</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">录入人姓名</label>
					<div class="layui-input-inline">
						<select name="entryName" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="胡小豪">胡小豪</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">在线备注</label>
					<div class="layui-input-inline">
						<input type="text" name="stuRemark" placeholder="请输入" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="tianjia">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
				<!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
			</form>
		</div>

		<div id="zixunc" style="display: none">
			<form class="layui-form" onsubmit="return false" id="zixunf">
				<!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
				<input type="hidden" name="use" value="aa" />
				<div class="layui-form-item">
					<label class="layui-form-label">咨询师</label>
					<div class="layui-input-inline">
						<select name="userId" lay-verify="required" class="layui-select">
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="zixun">立即提交</button>
					</div>
				</div>
				<!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
			</form>
		</div>

		<div id="xiugaic" style="display: none">
			<form class="layui-form" onsubmit="return false" id="xiugaif" lay-filter="xiugaif">
				<!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
				<div class="layui-form-item">
					<label class="layui-form-label">姓名</label>
					<div class="layui-input-inline">
						<input type="text" name="stuName" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">性别</label>
					<div class="layui-input-inline">
						<input type="radio" name="stuSex" value="男" title="男" checked>
						<input type="radio" name="stuSex" value="女" title="女">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">年龄</label>
					<div class="layui-input-inline">
						<input type="text" name="stuAge" lay-verify="age" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">电话</label>
					<div class="layui-input-inline">
						<input type="text" name="phone" lay-verify="phone" placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">学历</label>
					<div class="layui-input-inline">
						<select name="degree" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="本科">本科</option>
							<option value="大专">大专</option>
							<option value="高中">中专</option>
							<option value="高中">高中</option>
							<option value="初中">初中</option>
							<option value="初中">其他</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">状态</label>
					<div class="layui-input-inline">
						<select name="stuStatus" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="待业">待业</option>
							<option value="在职">在职</option>
							<option value="在读">在读</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">来源渠道</label>
					<div class="layui-input-inline">
						<select name="stuSources" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="百度移动端">百度移动端</option>
							<option value="360移动端">360移动端</option>
							<option value="搜狗移动端">搜狗移动端</option>
							<option value="UC移动端">UC移动端</option>
							<option value="直接输入">直接输入</option>
							<option value="QQ">QQ</option>
							<option value="微信">微信</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">来源网站</label>
					<div class="layui-input-inline">
						<select name="stuSourceSite" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="职英A站">职英A站</option>
							<option value="职英B站">职英B站</option>
							<option value="高考站">高考站</option>
							<option value="初中">其他</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">来源关键词</label>
					<div class="layui-input-inline">
						<select name="stuSourceKeyword" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="未知">未知</option>
							<option value="网络">网络</option>
							<option value="介绍">介绍</option>
							<option value="其他">其他</option>
						</select>
					</div>
					<!--	</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">来源部门</label>
					<div class="layui-input-inline">
						<select name="stuSourcesDepartment" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="课程">网络</option>
							<option value="学时">市场</option>
							<option value="学费">教质</option>
							<option value="学历">就业</option>
							<option value="就业">学术</option>
							<option value="其他">其他</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">所在区域</label>
					<div class="layui-input-inline">
						<select name="stuArea" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="郑州">郑州</option>
							<option value="新乡">新乡</option>
							<option value="周口">周口</option>
							<option value="焦作">焦作</option>
							<option value="鹤壁">鹤壁</option>
							<option value="其他">其他</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">学员关注</label>
					<div class="layui-input-inline">
						<select name="stuAttention" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="课程">课程</option>
							<option value="学时">学时</option>
							<option value="学费">学费</option>
							<option value="学历">学历</option>
							<option value="就业">就业</option>
							<option value="其他">其他</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">学员QQ</label>
					<div class="layui-input-inline">
						<input type="text" name="qq" placeholder="请输入" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">微信号</label>
					<div class="layui-input-inline">
						<input type="text" name="wechat" placeholder="请输入" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">是否报备</label>
					<div class="layui-input-inline">
						<select name="isReport" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="是">是</option>
							<option value="否">否</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">是否缴费</label>
					<div class="layui-input-inline">
						<select name="isFees" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="已缴费">已缴费</option>
							<option value="未缴费">未缴费</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">录入人姓名</label>
					<div class="layui-input-inline">
						<select name="entryName" lay-verify="required" class="layui-select">
							<option value="">请选择</option>
							<option value="胡小豪">胡小豪</option>
						</select>
					</div>
					<!--</div>
				<div class="layui-form-item">-->
					<label class="layui-form-label">在线备注</label>
					<div class="layui-input-inline">
						<input type="text" name="stuRemark" placeholder="请输入" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="xiugai">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
				<input type="hidden" name="id" />
				<!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
			</form>
		</div>

		<!-- 导入表格弹窗 -->
		<div id="uploadWindow" title="导入Excel数据" style="display: none">
			<input type="file" id="shangchuan" name="shangchuan">
			<input id="uploadBtn" type="button" value="开始上传" />
		</div>

		<script type="text/javascript">
			layui.use(['laydate', 'form', 'table', 'layer'], function() {
				var laydate = layui.laydate;
				var form = layui.form;
				var table = layui.table;
				var layer = layui.layer;
				var $ = layui.$;

				form.verify({
					age: [
						/^([1-9][0-9]{0,1}|100)$/, '年龄不符合'
					]
				})

				//执行渲染
				table.render({
					elem: '#demo' //指定原始表格元素选择器（推荐id选择器）
						,
					url: globalData.server + 'student/getStus',
					toolbar: '#barDemo1',
					where: {
						token: globalData.getToken()
					},
					page: true,
					//limit: 5,
					cols: [
						[{
							checkbox: true
						}, {
							field: 'id',
							title: 'id',
							sort: true,
							width: 80
						}, {
							field: 'stuName',
							title: '学生姓名',
							width: 100
						}, {
							field: 'stuSex',
							title: '性别',
							width: 80
						}, {
							field: 'stuAge',
							title: '年龄',
							width: 80
						}, {
							field: 'phone',
							title: '手机号',
							width: 120
						}, {
							field: 'degree',
							title: '学历',
							width: 100
						}, {
							field: 'qq',
							title: 'QQ',
							width: 100
						}, {
							field: 'wechat',
							title: '微信',
							width: 100
						}, {
							field: 'isFees',
							title: '是否缴费',
							width: 100
						}, {
							//field: 'userId',
							title: '咨询师id',
							width: 90,
							templet: function(d) {
								if(d.userId == null) {
									return "待分配"
								} else {
									return d.userId
								}
							}
						}, {
							//field: 'userId',
							title: '咨询师名称',
							width: 100,
							templet: function(d) {
								if(d.userId == null) {
									return "待分配"
								} else {
									return d.loginName
								}
							}
						}, {
							field: 'entryName',
							title: '录入人姓名',
							width: 100
						}, {
							toolbar: '#barDemo2',
							title: '操作'
						}]
					]
					//设置表头
					//,…… //更多参数参考右侧目录：基本参数选项
				});

				//搜索按钮的单击事件
				$("#souBtn").click(function() {

					//表格重载
					table.reload('demo', {
						where: {
							stuName: $("#stuName").val(),
							stuSex: $("#stuSex").val(),
							isFees: $("#isFees").val(),
							entryName: $("#entryName").val(),
							userId: $("#aa").val()
							//token:globalDate.getToken()
						}
					});
				});
				//搜索按钮的单击事件-end

				var zixunids = [];
				//监听工具条 
				table.on('toolbar(test)', function(obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"

					var layEvent = obj.event; //获得 lay-event 对应的值
					if(layEvent === 'add') { //添加
						//弹窗
						layer.open({
							type: 1,
							area: ['680px', '500px'],
							content: $("#tianjiac")
						})
					} else if(layEvent === 'daoru') { //导入
						//弹窗
						layer.open({
							type: 1,
							area: ['800px', '600px'],
							content: $('#uploadWindow')
						});
					} else if(layEvent==='yijianconfig'){
						var url=globalData.server+"student/setOnceAuto?token="+globalData.getToken();
						$.post(url,function(res){
							//layer.msg(res.msg);
							//table.reload('demo', {})
								if(res.code==0){
								 layer.msg(res.msg, {
								    icon: 1,
								    time:1500
								}, function () {
								    layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								});
							}else if(res.code==2){
								layer.msg(res.msg, {
								    icon: 7,
								    time:2000
								}, function () {
									layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								    //window.location.reload(); //刷新页面
								});
							}else{
								layer.msg(res.msg, {
								    icon: 7,
								    time:2000
								}, function () {
								   layer.closeAll(); //关闭所有的窗口
								table.reload('demo', {}); //表格重载
								});
							}
						}, "json")
					}else if(layEvent === 'daochu') { //导出
						var checkStatus = table.checkStatus('demo'); //demo 即为基础参数 id 对应的值
						console.log(checkStatus.data) //获取选中行的数据
						var ids = [];
						$(checkStatus.data).each(function(i, o) {
							ids.push(o.id);
						});
						if(ids.length < 1) {
							layer.confirm("未选中数据，您确定要导出所有的数据么？", function(index) {
								window.location.href = globalData.server + "stuexcel/exportStu?ids=" + ids + "&token=" + globalData.getToken();
								layer.msg("导出成功", {
									time: 1000,
									icon: 1
								})
								layer.close(index);
							})
						} else {
							ids = ids.join(",");
							layer.confirm("您确定要导出选中的数据么？", function(index) {
								window.location.href = globalData.server + "stuexcel/exportStu?ids=" + ids + "&token=" + globalData.getToken();
								layer.msg("导出成功", {
									time: 1000,
									icon: 1
								})
								layer.close(index);
							})
						}

					} else {
						var checkStatus = table.checkStatus('demo'); //demo 即为基础参数 id 对应的值
						console.log(checkStatus.data) //获取选中行的数据
						$(checkStatus.data).each(function(i, o) {
							zixunids.push(o.id);
						});
						console.log(zixunids);
						//弹窗
						layer.open({
							type: 1,
							area: ['500px', '500px'],
							content: $("#zixunc")
						})
					}
				});

				//监听工具条 
				table.on('tool(test)', function(obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
					var data = obj.data; //获得当前行数据
					var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
					var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

					if(layEvent === 'del') { //删除
						layer.confirm('真的删除学生信息吗', {
							icon: 3
						}, function(index) {
							//obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
							layer.close(index);
							//向服务端发送删除指令
							$.post(globalData.server + "student/delStudent?token=" + globalData.getToken(), {
								id: data.id
							}, function(res) {
								layer.msg(res.msg, {
									icon: 1,
									time: 1500
								}, function() {
									layer.closeAll();
									table.reload('demo', {})
								})
							}, "json")
						});
					} else if(layEvent === 'edit') { //编辑
						console.log(data)
						form.val("xiugaif", data)
						//弹窗
						layer.open({
							type: 1,
							area: ['680px', '500px'],
							content: $("#xiugaic")
						})
					} else if(layEvent === 'zhuizongedit') { //追踪记录查看
						//弹窗
						layer.open({
							type: 1,
							title:'追踪记录',
							area: ['700px', '500px'],
							content: $("#zhuizonglook")
						})

						//渲染表格
						table.render({
							elem: '#demo1', //指定原始表格元素选择器（推荐id选择器）
							page: true, //开启分页
							url: globalData.server + 'track/getStuTrack', //数据接口
							where: {
								token: globalData.getToken(),
								stuId: data.id
							},
							method: "post",
							toolbar: '#barDemo3',
							//limit:2,
							cols: [
								[ //标题栏
									{
										checkbox: true
									}/*, {
										field: 'id',
										title: '编号',
										sort: true,
										width: 120
									}*/, {
										field: 'stuId',
										title: '学生id',
										//sort: true,
										width: 90
									}, {
										field: 'trackTime',
										title: '跟踪时间',
										width: 160
									}, {
										field: 'reviewSituation',
										title: '回访情况',
										width: 100
									}, {
										field: 'trackMode',
										title: '跟踪方式',
										width: 100
									}, {
										field: 'content',
										title: '跟踪内容',
										width: 100
									}, {
										field: 'nextTrackTime',
										title: '下次跟踪时间',
										width: 160
									}, {
										field: 'trackRemark',
										title: '备注',
										width: 100
									}
								]
							]
						});
						//渲染表格--end
					}
					
				});

				//添加提交的 监听
				form.on('submit(tianjia)', function(data) {
					$.post(globalData.server + "student/addStu?token=" + globalData.getToken(), data.field,
						function(res) {
							if(res.code == 0) {
								layer.alert(res.msg, {
									icon: 1,
									time: 2000
								}, function() {
									layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								});
							} else if(res.code == 2) {
								layer.msg(res.msg, {
									icon: 7,
									time: 2000
								}, function() {
									//layer.closeAll(); //关闭所有的窗口
									//table.reload('demo', {}); //表格重载
								});
							} else {
								layer.msg(res.msg, {
									icon: 7,
									time: 2000
								}, function() {
									layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								});
							}
						}, "json")
				}) //添加提交的 监听--end

				//修改提交的 监听
				form.on('submit(xiugai)', function(data) {
					$.post(globalData.server + "student/updateStudent?token=" + globalData.getToken(), data.field,
						function(res) {
							if(res.code == 0) {
								layer.alert(res.msg, {
									icon: 1,
									time: 2000
								}, function() {
									layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								});
							} else if(res.code == 2) {
								layer.msg(res.msg, {
									icon: 7,
									time: 2000
								}, function() {
									layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								});
							} else {
								layer.msg(res.msg, {
									icon: 7,
									time: 2000
								}, function() {
									layer.closeAll(); //关闭所有的窗口
									table.reload('demo', {}); //表格重载
								});
							}
						}, "json")
				}) //修改提交的 监听--end

				//分量提交的 监听
				form.on('submit(zixun)', function(data) {
					console.log(zixunids)
					console.log(data.field)
					console.log(data.field.userId)
					console.log(data.field.use)
					//var ids=zixunids.toString();
					//console.log(ids);
					if(zixunids.length < 1) {
						layer.msg("请选择数据")
					} else {
						var ids = zixunids.join(",");
						$.post(globalData.server + "student/autoUser?token=" + globalData.getToken(), {
							ids: ids,
							uid: data.field.userId
						}, function(res) {
							layer.alert(res.msg, function() {
								layer.closeAll();
								table.reload('demo', {})
							})
						}, "json")
					}

				}) //分量提交的 监听-end


			//文件导入 按钮单击时执行
			$("#uploadBtn").click(function(){
				var formData = new FormData();//表单数据对象				
				formData.append("file", $("#shangchuan").prop('files')[0] );//文件				
				$.ajax({
					url:globalData.server + "stuexcel/uploadStu?token=" + globalData.getToken(),
					type: 'POST',
					data: formData,
					dataType:'json',
					// 告诉jQuery不要去处理发送的数据
					processData: false,
					// 告诉jQuery不要去设置Content-Type请求头
					contentType: false,
					beforeSend: function() {
						console.log("正在拼命上传文件，请稍候...");
					},
					success: function(result) {
						console.log(result);
						if(result.data){
							layer.closeAll(); //关闭所有的窗口
							table.reload('demo', {}); //表格重载
						}else{
							layer.msg("添加失败，学生名称不能重复添加",{
								icon:7,
								time:1500
							},function () {
									layer.closeAll(); //关闭所有的窗口
									//table.reload('demo', {}); //表格重载
								    window.location.reload(); //刷新页面
								});
						}
					}
				});
			})//文件导入 按钮单击时执行--end



				//html页面获取集合
				$.post(globalData.server + "user/getZiXunShiList?token=" + globalData.getToken(), function(res) {
					if(res.data) {
						console.log(res.data)
						$("[name=userId]").empty() //清空下拉框
						$("[name=userId]").append("<option value=''>请选择</option>")
						for(var i = 0; i < res.data.length; i++) {
							console.log("aa")
							if(res.data[i].qiandaoState.equals == "已签到") {
								console.log("bb")
							}
							var item = res.data[i];
							console.log(item);
							$("[name=userId]").append("<option value='" + item.id + "'>" + item.id + "-" + item.loginName + "</option>")
						}
						$("[name=userId]").append("<option value='-1'>待分配</option>")
						//重新渲染select
						form.render('select');
					}
				})

				//html异步请求获取关联的外键表并渲染
				var url = globalData.server + "user/getWangLuoZiXunShiList?token=" + globalData.getToken();
				$.post(url, function(res) {
					if(res.data) {
						$("[name=entryName]").empty(); //清空下拉框
						$("[name=entryName]").append("<option value=''>请选择</option>");
						for(var i = 0; i < res.data.length; i++) {
							var item = res.data[i];
							$("[name=entryName]").append("<option value=" + item.loginName + ">" + item.loginName + "</option>");
						}
						//重新渲染select
						form.render('select');
					}
				})

			});
		</script>
	</body>

</html>